/**
* @description: TODO
* @author hewei
* @date 2022/9/24 15:14
* @version 1.0
*/

public class TemperatureTrend {

    public int temperatureTrend(int[] temperatureA, int[] temperatureB) {
        int l = 0;
        int r = 0;
        int ans = 0;
        while (r < temperatureA.length - 1) {
            if (check(temperatureA[r], temperatureA[r + 1]) == check(temperatureB[r], temperatureB[r + 1])) {
                ++r;
                ans = Math.max(ans, r - l);
            } else {
                ++r;
                l = r;
            }
        }
        return ans;
    }

    public int check(int l , int r) {
        if (l == r) return 0;
        if (l < r) return 1;
        return -1;
    }
}
